<template>
  <div class="app-navigation">
    <div class="nav-header">
      <h2>爱吃兔溯源管理系统</h2>
    </div>
    
    <div class="nav-menu">
      <div class="menu-section">
        <h3>系统管理</h3>
        <div class="menu-items">
          <router-link 
            to="/company-manage" 
            class="menu-item"
            :class="{ active: $route.name === 'companyManage' }"
          >
            <i class="icon-company"></i>
            <span>企业管理</span>
          </router-link>
          
          <router-link 
            to="/traceability" 
            class="menu-item"
            :class="{ active: $route.name === 'traceability' }"
          >
            <i class="icon-trace"></i>
            <span>溯源管理</span>
          </router-link>
          
          <router-link 
            to="/product-detail" 
            class="menu-item"
            :class="{ active: $route.name === 'productDetail' }"
          >
            <i class="icon-product"></i>
            <span>产品详情</span>
          </router-link>
        </div>
      </div>
      
      <div class="menu-section">
        <h3>系统设置</h3>
        <div class="menu-items">
          <router-link 
            to="/home" 
            class="menu-item"
            :class="{ active: $route.name === 'home' }"
          >
            <i class="icon-home"></i>
            <span>首页</span>
          </router-link>
          
          <router-link 
            to="/about" 
            class="menu-item"
            :class="{ active: $route.name === 'about' }"
          >
            <i class="icon-about"></i>
            <span>关于</span>
          </router-link>
        </div>
      </div>
    </div>
    
    <div class="nav-footer">
      <div class="user-info">
        <div class="avatar">U</div>
        <div class="user-details">
          <div class="username">管理员</div>
          <div class="role">系统管理员</div>
        </div>
      </div>
      
      <div class="logout-btn" @click="logout">
        <i class="icon-logout"></i>
        <span>退出登录</span>
      </div>
    </div>
  </div>
</template>

<script setup lang="ts">
import { useRouter } from 'vue-router'
import { ElMessage } from 'element-plus'

const router = useRouter()

const logout = () => {
  ElMessage.success('退出登录成功')
  router.push('/')
}
</script>

<style scoped>
.app-navigation {
  width: 250px;
  height: 100vh;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  display: flex;
  flex-direction: column;
  color: white;
  position: fixed;
  left: 0;
  top: 0;
  z-index: 1000;
}

.nav-header {
  padding: 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.nav-header h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  text-align: center;
}

.nav-menu {
  flex: 1;
  padding: 20px 0;
  overflow-y: auto;
}

.menu-section {
  margin-bottom: 30px;
}

.menu-section h3 {
  margin: 0 0 15px 0;
  padding: 0 20px;
  font-size: 14px;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.7);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.menu-items {
  display: flex;
  flex-direction: column;
}

.menu-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  color: rgba(255, 255, 255, 0.8);
  text-decoration: none;
  transition: all 0.3s ease;
  position: relative;
}

.menu-item:hover {
  background: rgba(255, 255, 255, 0.1);
  color: white;
}

.menu-item.active {
  background: rgba(255, 255, 255, 0.15);
  color: white;
}

.menu-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background: white;
}

.menu-item i {
  font-size: 16px;
  width: 20px;
  text-align: center;
}

/* 图标样式 */
.icon-company::before { content: '🏢'; }
.icon-trace::before { content: '🔍'; }
.icon-product::before { content: '📦'; }
.icon-home::before { content: '🏠'; }
.icon-about::before { content: 'ℹ️'; }
.icon-logout::before { content: '🚪'; }

.nav-footer {
  padding: 20px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.user-info {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 15px;
}

.avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 16px;
}

.user-details {
  flex: 1;
}

.username {
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 2px;
}

.role {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.6);
}

.logout-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.1);
  cursor: pointer;
  transition: background 0.3s ease;
  font-size: 14px;
}

.logout-btn:hover {
  background: rgba(255, 255, 255, 0.2);
}

.logout-btn i {
  font-size: 14px;
}
</style>


